// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.asm;

import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;

import com.dustedpixels.asm.core.Class;
import com.dustedpixels.asm.core.Method;


/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class ClassMethodSupplier implements MethodSupplier {

  private final Class clazz;
  
  public ClassMethodSupplier(Class clazz) {
    this.clazz = clazz;
  }
  
  public Method get(String name, String desc) {
    return null;
  }
  
  private final static class MethodReceiver extends ClassAdapter {
    private final String name;
    private final String desc;
    private Method method;
    
    public MethodReceiver(String name, String desc) {
      super(ClassVisitors.nullify());
      this.name = name;
      this.desc = desc;
      this.method = null;
    }

    @Override
    public MethodVisitor visitMethod(
        int access, 
        String name, 
        String desc, 
        String signature,
        String[] exceptions) {
      
      MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
      if (methodVisitor != null && name.equals(this.name) && desc.equals(this.desc)) {
        this.method = methodVisitor;
      }
      return methodVisitor;
    }
  }
}
